<template>
  <view>
    <u-navbar :is-back="false" title="订单"
      title-size="30"
      :background="{background:'#2B88FE' }"
      title-color="#fff">
      <div class="head_icon">
        <u-icon @click="$api.handleBackTo"
          name="arrow-left" color="#fff"
          size="36">
        </u-icon>
        <u-icon @click="$api.handleHomeTo"
          name="home" color="#fff" size="36">
        </u-icon>
      </div>
    </u-navbar>
    <CommDetail :cid="cid" :info="info"
      :current="3">
      <u-tabs :list="tabs"
        :current="form.OrderStatus" height="96"
        active-color="#3296FA"
        inactive-color="#999" @change="change">
      </u-tabs>
      <orlist v-for="(item,index) in list"
        :item="item" :key="index">
        <u-button type="primary" size="medium"
          slot="button"
          @click="$api.navigator(`/pages/sale/order_detail?id=${item.fId}&taskId=${item.fTaskId}&status=order`)">
          {{getStatus(item.fStatus)}}
        </u-button>
      </orlist>
      <u-empty text="暂无数据" mode="list"
        v-if="!list.length">
      </u-empty>
    </CommDetail>
  </view>
</template>

<script>
import { taskStatus } from '@/util/setting'
import orlist from '@/components/orlist'
import CommDetail from './commdetail'
export default {
  components: { orlist, CommDetail },
  data() {
    return {
      cid: 0,
      info: {},
      tabs: [
        {
          name: '全部'
        },
        {
          name: '待审核'
        },
        {
          name: '待分配'
        },
        {
          name: '待配送'
        },
        {
          name: '待收款'
        },
        {
          name: '未结清'
        },

        {
          name: '已完成'
        }
      ],
      list: [],
      form: {
        OrderType: 0,
        MrkId: 0,
        OrderStatus: 0
      }
    }
  },
  methods: {
    getStatus(status) {
      return taskStatus[status]
    },
    getList() {
      this.$axios('api/OrderBasic/ListMrkPaged', 'post', { value: this.form }).then(res => {
        res.Value.List.forEach(x => {
          x.id = x.fId
          x.name = x.fMrkName
        })
        this.list = res.Value.List
      })
    },
    change(e) {
      this.form.OrderStatus = e
      this.getList()
    }
  },
  onLoad(e) {
    this.cid = Number(e.id)
    this.form.MrkId = this.cid
    this.$axios('api/MrkBasic/GetDetail', 'post', {
      value: e.id
    }).then(res => {
      this.info = res.Value
      this.loading = false
      // this.form.MrkId = this.info.this.getList()
    })
    this.getList()
  }
}
</script>

<style lang="scss" scoped>
</style>